#include "display_info_button.h"
#include "ui_display_info_button.h"
#include <QStyleOption>
#include <QPainter>

DisplayInfoButton::DisplayInfoButton(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::DisplayInfoButton)
{
    ui->setupUi(this);
}

DisplayInfoButton::~DisplayInfoButton()
{
    delete ui;
}

void DisplayInfoButton::setInfo(QIcon icon, QString key, QString value)
{
    ui->iconLabel->setPixmap(icon.pixmap(24, 24));
    ui->keyLabel->setText(key);
    ui->valueLabel->setText(value);
}

void DisplayInfoButton::setValue(QString value)
{
    ui->valueLabel->setText(value);
}

void DisplayInfoButton::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);
    QStyleOption opt;
    opt.initFrom(this);
    QPainter p(this);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}

void DisplayInfoButton::mouseReleaseEvent(QMouseEvent *event)
{
    emit(clicked());
}
